package com.chixing.ih.module.task.mapper;

import com.chixing.ih.common.IhRepository;
import com.chixing.ih.module.task.mapper.provider.ChargeBackMapperProvider;
import com.chixing.ih.module.task.mapper.provider.OrderMapperProvider;
import com.chixing.ih.module.task.pojo.ChargeBack;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 目的:
 *
 * @author ：zcw
 * @version: 1.0  2020/9/25 23:01
 */
@Mapper
public interface ChargeBackMapper extends IhRepository<ChargeBack> {
    @InsertProvider(type = ChargeBackMapperProvider.class, method = "saveOne")
    int saveOne(ChargeBack chargeBack);

    @DeleteProvider(type = ChargeBackMapperProvider.class, method = "deleteOne")
    int deleteOne(Long changeBackId);

    @UpdateProvider(type = ChargeBackMapperProvider.class, method = "updateOne")
    int updateOne(ChargeBack chargeBack);

    @SelectProvider(type = OrderMapperProvider.class, method = "getOne")
    @Results(id = "chargeBackMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "order_id", property = "orderId"),
            @Result(column = "refund_amount", property = "refundAmount"),
            @Result(column = "reason_for_refund", property = "reasonForRefund"),
            @Result(column = "is_deleted", property = "logicalDeletion"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "out_request_no", property = "outRequestNo")
    })
    ChargeBack findOne(Long changeBackId);

    @ResultMap({"chargeBackMap"})
    List<ChargeBack> findAll();

}
